home *** CD-ROM | disk | FTP | other *** search
/ Night Owl 6 / Night Owl's Shareware - PDSI-006 - Night Owl Corp (1990).iso / 020a / intgif11.zip / PARAM.PAS < prev   
Pascal/Delphi Source File  |  1990-07-18  |  3KB  |  108 lines

  1. {-------------------------------------------------------------------------}
  2. {                                                                         }
  3. { Param - Parameter Parsing Unit - Copyright (c) EUROPA Software, 1990    }
  4. {         Last Alteration  -  October 18                                  }
  5. {                                                                         }
  6. {-------------------------------------------------------------------------}
  7.  
  8. unit param;
  9.  
  10.    interface
  11.  
  12.    const MaxParams  = 20;
  13.          crlf       = #10 + #13;
  14.  
  15.    type ParamArray = RECORD
  16.  
  17.         SpecCount    :  byte;
  18.         Spec         :  array[1..MaxParams] of string;
  19.         SwitchCount  :  byte;
  20.         Switch       :  array[1..MaxParams] of string;
  21.  
  22.    end;
  23.  
  24.  
  25.    function ParseCommandLine( var CommandLine  :  ParamArray )   :  boolean;
  26.  
  27.  
  28.    implementation
  29.  
  30.  
  31.    function ToUpCase( InString  :  string )  :  string;
  32.  
  33.       var i   :  byte;
  34.           st  :  string;
  35.  
  36.       begin
  37.  
  38.          st := '';
  39.  
  40.          for i := 1 to length(InString) do st := st + upcase(InString[i]);
  41.  
  42.          ToUpCase := st;
  43.  
  44.       end;
  45.  
  46.  
  47.    function ParseCommandLine( var CommandLine  :  ParamArray )  :  boolean;
  48.  
  49.       var ParseCount  :  byte;
  50.           i,k         :  byte;
  51.           st          :  string;
  52.  
  53.       begin
  54.  
  55.          CommandLine.SpecCount   := 0;
  56.          CommandLine.SwitchCount := 0;
  57.  
  58.          for i := 1 to paramcount do begin
  59.  
  60.              st := paramstr(i);
  61.  
  62.              if (st[1] = '-') OR (st[1] = '/') then begin
  63.  
  64.                 for k := 2 to length(st) do
  65.  
  66.                     if CommandLine.SwitchCount < MaxParams then begin
  67.  
  68.                        inc(CommandLine.SwitchCount);
  69.                        CommandLine.Switch[CommandLine.SwitchCount] := st[k];
  70.  
  71.                     end
  72.                     else begin
  73.  
  74.                        ParseCommandLine := false;
  75.                        exit;
  76.  
  77.                     end;
  78.  
  79.              end
  80.              else begin
  81.  
  82.                 if CommandLine.SpecCount < MaxParams then begin
  83.  
  84.                    inc(CommandLine.SpecCount);
  85.                    CommandLine.Spec[CommandLine.SpecCount] := ToUpCase(st);
  86.  
  87.                 end
  88.                 else begin
  89.  
  90.                    ParseCommandLine := false;
  91.                    exit;
  92.  
  93.                 end;
  94.  
  95.              end;
  96.  
  97.              ParseCommandLine := true;
  98.  
  99.          end;
  100.  
  101.       end;
  102.  
  103.  
  104.    begin
  105.  
  106.    end.
  107.  
  108.